import React from 'react'
import Child1 from './Child1'
import Child2 from './Child2'

export default class Parent extends React.Component {
  constructor () {
    super()

    this.state = {
      isMan: true
    }
  }

  changeValue = value => {
    this.setState({
      isMan: value
    })
  }

  render () {
    return (
      <div>
        <p>我是父组件</p>
        {/* 属性值就两种，要么字符串，要么是表达式 
        最外层的{} 就是表达式
        */}
        <Child1
          name='小丽'
          age={18}
          hobby={['打王者荣耀', '吃肯德基', '打羽毛球']}
        />
        <hr />
        {/* 外层是表达式，里面是对象 */}
        <Child2
          isMan={this.state.isMan}
          address={{ province: '江西', city: '赣州' }}
          callback={this.changeValue}
        />
      </div>
    )
  }
}
